package com.keyinong.caizhengting.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.keyinong.caizhengting.R;
import com.keyinong.caizhengting.entity.AddressEntity;

import java.util.ArrayList;

/**
 * popWindow下拉适配器
 */

public class PopwindowAdapter2 extends BaseAdapter {
    ArrayList<AddressEntity> list;
    Context context;

    public PopwindowAdapter2(ArrayList<AddressEntity> list, Context context) {
        super();
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        ViewHandler handler;
        if (view == null) {
            handler = new ViewHandler();
            view = LayoutInflater.from(context).inflate(
                    R.layout.item_popup_sreachtype, null);
            handler.tv_ppsreachtype = (TextView) view.findViewById(R.id.tv_ppsreachtype);
            view.setTag(handler);
        } else {
            handler = (ViewHandler) view.getTag();
        }
        handler.tv_ppsreachtype.setText(list.get(position).getName());
        return view;
    }

    private class ViewHandler {
        TextView tv_ppsreachtype;
    }

}
